<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>tinymce.html.SaxParser tests</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" />
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
<script src="qunit/connector.js"></script>
<script type="text/javascript" src="qunit/runner.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/tiny_mce_loader.js"></script>
<script>
module("tinymce.html.SaxParser");

QUnit.config.reorder = false;

var writer = new tinymce.html.Writer(), schema = new tinymce.html.Schema();

function createCounter(writer) {
	var counts = {};

	return {
		counts : counts,

		comment: function(text) {
			if ("comment" in counts)
				counts.comment++;
			else
				counts.comment = 1;

			writer.comment(text);
		},

		cdata: function(text) {
			if ("cdata" in counts)
				counts.cdata++;
			else
				counts.cdata = 1;

			writer.cdata(text);
		},

		text: function(text, raw) {
			if ("text" in counts)
				counts.text++;
			else
				counts.text = 1;

			writer.text(text, raw);
		},

		start: function(name, attrs, empty) {
			if ("start" in counts)
				counts.start++;
			else
				counts.start = 1;

			writer.start(name, attrs, empty);
		},

		end: function(name) {
			if ("end" in counts)
				counts.end++;
			else
				counts.end = 1;

			writer.end(name);
		},

		pi: function(name, text) {
			if ("pi" in counts)
				counts.pi++;
			else
				counts.pi = 1;

			writer.pi(name, text);
		},

		doctype: function(text) {
			if ("doctype:" in counts)
				counts.doctype++;
			else
				counts.doctype = 1;

			writer.doctype(text);
		}
	};
}

test('Parse elements', function() {
	expect(46);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span id=id1 title="title value" class=\'class1 class2\' data-value="value1" MYATTR="val1" myns:myattr="val2" disabled empty=""></span>');
	equal(writer.getContent(), '<span id="id1" title="title value" class="class1 class2" data-value="value1" myattr="val1" myns:myattr="val2" disabled="disabled" empty=""></span>', 'Parse attribute formats.');
	deepEqual(counter.counts, {start:1, end:1}, 'Parse attribute formats counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<b href=\'"&amp;<>\'></b>');
	equal(writer.getContent(), '<b href="&quot;&amp;&lt;&gt;"></b>', 'Parse attributes with <> in them.');
	deepEqual(counter.counts, {start:1, end:1}, 'Parse attributes with <> in them (count).');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span title=" "class=" "></span>');
	equal(writer.getContent(), '<span title=" " class=" "></span>', 'Parse compressed attributes.');
	deepEqual(counter.counts, {start:1, end:1}, 'Parse compressed attributes (count).');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span title></span>');
	equal(writer.getContent(), '<span title=""></span>', 'Single empty attribute.');
	deepEqual(counter.counts, {start:1, end:1}, 'Single empty attributes (count).');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span class="class" title></span>');
	equal(writer.getContent(), '<span class="class" title=""></span>', 'Empty attribute at end.');
	deepEqual(counter.counts, {start:1, end:1}, 'Empty attribute at end (count).');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span title class="class"></span>');
	equal(writer.getContent(), '<span title="" class="class"></span>', 'Empty attribute at start.');
	deepEqual(counter.counts, {start:1, end:1}, 'Empty attribute at start (count).');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<img src="test">');
	equal(writer.getContent(), '<img src="test" />', 'Parse empty element.');
	deepEqual(counter.counts, {start:1}, 'Parse empty element counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<img\nsrc="test"\ntitle="row1\nrow2">');
	equal(writer.getContent(), '<img src="test" title="row1\nrow2" />', 'Parse attributes with linebreak.');
	deepEqual(counter.counts, {start: 1}, 'Parse attributes with linebreak counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<img     \t  \t   src="test"     \t  \t   title="\t    row1\t     row2">');
	equal(writer.getContent(), '<img src="test" title="\t    row1\t     row2" />', 'Parse attributes with whitespace.');
	deepEqual(counter.counts, {start: 1}, 'Parse attributes with whitespace counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<myns:mytag>text</myns:mytag>');
	equal(writer.getContent(), '<myns:mytag>text</myns:mytag>', 'Parse element with namespace.');
	deepEqual(counter.counts, {start:1, text:1, end: 1}, 'Parse element with namespace counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<myns-mytag>text</myns-mytag>');
	equal(writer.getContent(), '<myns-mytag>text</myns-mytag>', 'Parse element with dash name.');
	deepEqual(counter.counts, {start:1, text:1, end:1}, 'Parse element with dash name counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<p>text2<b>text3</p>text4</b>text5');
	equal(writer.getContent(), 'text1<p>text2<b>text3</b></p>text4text5', 'Parse tag soup 1.');
	deepEqual(counter.counts, {text:5, start: 2, end: 2}, 'Parse tag soup 1 counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<P>text2<B>text3</p>text4</b>text5');
	equal(writer.getContent(), 'text1<p>text2<b>text3</b></p>text4text5', 'Parse tag soup 2.');
	deepEqual(counter.counts, {text: 5, start: 2, end: 2}, 'Parse tag soup 2 counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<P>text2<B>tex<t3</p>te>xt4</b>text5');
	equal(writer.getContent(), 'text1<p>text2<b>tex&lt;t3</b></p>te&gt;xt4text5', 'Parse tag soup 3.');
	deepEqual(counter.counts, {text: 5, start: 2, end: 2}, 'Parse tag soup 3 counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<p>text2<b>text3');
	equal(writer.getContent(), 'text1<p>text2<b>text3</b></p>', 'Parse tag soup 4.');
	deepEqual(counter.counts, {text: 3, start: 2, end: 2}, 'Parse tag soup 4 counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<script>text2');
	equal(writer.getContent(), 'text1<script>text2</s' + 'cript>', 'Parse tag soup 5.');
	deepEqual(counter.counts, {text: 2, start: 1, end: 1}, 'Parse tag soup 5 counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<style>text2');
	equal(writer.getContent(), 'text1<style>text2</st' + 'yle>', 'Parse tag soup 6.');
	deepEqual(counter.counts, {text: 2, start: 1, end: 1}, 'Parse tag soup 6 counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<span title="<test" data-test="test>"></span>');
	equal(writer.getContent(), 'text1<span title="&lt;test" data-test="test&gt;"></span>', 'Parse element with </> in attributes.');
	deepEqual(counter.counts, {text: 1, start: 1, end: 1}, 'Parse element with </> in attributes counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse("text\n<SC"+"RIPT type=mce-text/javascript>// <![CDATA[\nalert('HELLO WORLD!');\n// ]]></SC"+"RIPT>");
	equal(writer.getContent(), "text\n<sc"+"ript type=\"mce-text/javascript\">// <![CDATA[\nalert('HELLO WORLD!');\n// ]]></sc"+"ript>", 'Parse cdata script.');
	deepEqual(counter.counts, {text: 2, start: 1, end: 1}, 'Parse cdata script counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<noscript>te<br>xt2</noscript>text3');
	equal(writer.getContent(), 'text1<noscript>te<br>xt2</noscript>text3', 'Parse noscript elements.');
	deepEqual(counter.counts, {text: 3, start: 1, end: 1}, 'Parse noscript elements counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<p>a</p><p /><p>b</p>');
	equal(writer.getContent(), '<p>a</p><p></p><p>b</p>', 'Parse invalid closed element.');
	deepEqual(counter.counts, {text: 2, start: 3, end: 3}, 'Parse invalid closed element counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<br><br /><br/>');
	equal(writer.getContent(), '<br /><br /><br />', 'Parse short ended elements.');
	deepEqual(counter.counts, {start: 3}, 'Parse short ended elements counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<p ></p>');
	equal(writer.getContent(), '<p></p>', 'Parse start elements with whitespace only attribs part.');
	deepEqual(counter.counts, {start: 1, end: 1}, 'Parse start elements with whitespace only attribs part (counts).');
});

test('Parse style elements', function() {
	expect(8);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<span><style>// <b>tag</b></st' + 'yle>text2</span>');
	equal(writer.getContent(), 'text1<span><style>// <b>tag</b></st' + 'yle>text2</span>', 'Parse style element.');
	deepEqual(counter.counts, {start: 2, end: 2, text: 3}, 'Parse style element counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<span><style id="id">// <b>tag</b></st' + 'yle>text2</span>');
	equal(writer.getContent(), 'text1<span><style id="id">// <b>tag</b></st' + 'yle>text2</span>', 'Parse style element with attributes.');
	deepEqual(counter.counts, {text:3, start:2, end:2}, 'Parse style element with attributes counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<span><style></st' + 'yle>text2</span>');
	equal(writer.getContent(), 'text1<span><style></st' + 'yle>text2</span>', 'Parse empty style element.');
	deepEqual(counter.counts, {text:2, start:2, end:2}, 'Parse empty style element counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(tinymce.extend({validate : true}, counter), new tinymce.html.Schema({invalid_elements: 'style'}));
	writer.reset();
	parser.parse('text1<span><style>text2</st' + 'yle>text3</span>');
	equal(writer.getContent(), 'text1<span>text3</span>', 'Parse invalid style element.');
	deepEqual(counter.counts, {text:2, start:1, end:1}, 'Parse invalid style element (count).');
});

test('Parse script elements', function() {
	expect(8);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<span><script>// <b>tag</b></s' + 'cript>text2</span>');
	equal(writer.getContent(), 'text1<span><script>// <b>tag</b></s' + 'cript>text2</span>', 'Parse script element.');
	deepEqual(counter.counts, {start:2, end:2, text:3}, 'Parse script element counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<span><script id="id">// <b>tag</b></s' + 'cript>text2</span>');
	equal(writer.getContent(), 'text1<span><script id="id">// <b>tag</b></s' + 'cript>text2</span>', 'Parse script element with attributes.');
	deepEqual(counter.counts, {start:2, end:2, text:3}, 'Parse script element with attributes counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<span><script></s' + 'cript>text2</span>');
	equal(writer.getContent(), 'text1<span><script></s' + 'cript>text2</span>', 'Parse empty script element.');
	deepEqual(counter.counts, {text: 2, start:2, end: 2}, 'Parse empty script element counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(tinymce.extend({validate : true}, counter), new tinymce.html.Schema({invalid_elements: 'script'}));
	writer.reset();
	parser.parse('text1<span><s' + 'cript>text2</s' + 'cript>text3</span>');
	equal(writer.getContent(), 'text1<span>text3</span>', 'Parse invalid script element.');
	deepEqual(counter.counts, {text:2, start:1, end:1}, 'Parse invalid script element (count).');
});

test('Parse text', function() {
	expect(10);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('');
	equal(writer.getContent(), '', 'Parse empty.');
	deepEqual(counter.counts, {}, 'Parse empty counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text');
	equal(writer.getContent(), 'text', 'Parse single text node.');
	deepEqual(counter.counts, {text: 1}, 'Parse single text node counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<b>text</b>');
	equal(writer.getContent(), '<b>text</b>', 'Parse wrapped text.');
	deepEqual(counter.counts, {start:1, text:1, end:1}, 'Parse wrapped text counts');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('text1<b>text2</b>');
	equal(writer.getContent(), 'text1<b>text2</b>', 'Parse text at start.');
	deepEqual(counter.counts, {start:1, text:2, end:1}, 'Parse text at start counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<b>text1</b>text2');
	equal(writer.getContent(), '<b>text1</b>text2', 'Parse text at end.');
	deepEqual(counter.counts, {start:1, end:1, text:2}, 'Parse text at end counts.');
});

test('Parsing comments', function() {
	expect(8);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<!-- comment value -->');
	equal(writer.getContent(), '<!-- comment value -->', 'Parse comment with value.');
	deepEqual(counter.counts, {comment:1}, 'Parse comment with value count.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<!---->');
	equal(writer.getContent(), '', 'Parse comment without value.');
	deepEqual(counter.counts, {}, 'Parse comment without value count.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<!--<b></b>-->');
	equal(writer.getContent(), '<!--<b></b>-->', 'Parse comment with tag inside.');
	deepEqual(counter.counts, {comment:1}, 'Parse comment with tag inside counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<b>a<!-- value -->b</b>');
	equal(writer.getContent(), '<b>a<!-- value -->b</b>', 'Parse comment with tags around it.');
	deepEqual(counter.counts, {comment:1, text:2, start:1, end:1}, 'Parse comment with tags around it counts.');
});

test('Parsing cdata', function() {
	expect(8);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<![CDATA[test text]]>');
	equal(writer.getContent(), '<![CDATA[test text]]>', 'Parse cdata with value.');
	deepEqual(counter.counts, {cdata:1}, 'Parse cdata with value counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<![CDATA[]]>');
	equal(writer.getContent(), '', 'Parse cdata without value.');
	deepEqual(counter.counts, {}, 'Parse cdata without value counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<![CDATA[<b>a</b>]]>');
	equal(writer.getContent(), '<![CDATA[<b>a</b>]]>', 'Parse cdata with tag inside.');
	deepEqual(counter.counts, {cdata:1}, 'Parse cdata with tag inside counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<b>a<![CDATA[value]]>b</b>');
	equal(writer.getContent(), '<b>a<![CDATA[value]]>b</b>', 'Parse cdata with tags around it.');
	deepEqual(counter.counts, {cdata:1, start:1, end:1, text:2}, 'Parse cdata with tags around it counts.');
});

test('Parse PI', function() {
	expect(6);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<?xml version="1.0" encoding="UTF-8" ?>text1');
	equal(writer.getContent(), '<?xml version="1.0" encoding="UTF-8" ?>text1', 'Parse PI with attributes.');
	deepEqual(counter.counts, {pi:1, text:1}, 'Parse PI with attributes counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<?xml?>text1');
	equal(writer.getContent(), '<?xml?>text1', 'Parse PI with no data.');
	deepEqual(counter.counts, {pi:1, text:1}, 'Parse PI with data counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<?xml somevalue/>text1');
	equal(writer.getContent(), '<?xml somevalue?>text1', 'Parse PI with IE style ending.');
	deepEqual(counter.counts, {pi:1, text:1}, 'Parse PI with IE style ending counts.');
});

test('Parse doctype', function() {
	expect(4);

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">text1');
	equal(writer.getContent(), '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">text1', 'Parse DOCTYPE.');
	deepEqual(counter.counts, {doctype:1, text:1}, 'Parse HTML5 DOCTYPE counts.');

	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<!DOCTYPE html>text1');
	equal(writer.getContent(), '<!DOCTYPE html>text1', 'Parse HTML5 DOCTYPE.');
	deepEqual(counter.counts, {doctype:1, text:1}, 'Parse HTML5 DOCTYPE counts.');
});

test('Parse (validate)', function() {
	expect(2);

	var counter = createCounter(writer);
	counter.validate = true;
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<invalid1>123<invalid2 />456<span title="title" invalid3="value">789</span>012</invalid1>');
	equal(writer.getContent(), '123456<span title="title">789</span>012', 'Parse invalid elements and attributes.');
	deepEqual(counter.counts, {start:1, end:1, text:4}, 'Parse invalid elements and attributes counts.');
});

test('Self closing', function() {
	expect(1);

	var counter = createCounter(writer);
	counter.validate = true;
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<ul><li>1<li><b>2</b><li><em><b>3</b></em></ul>');
	equal(writer.getContent(), '<ul><li>1</li><li><b>2</b></li><li><em><b>3</b></em></li></ul>', 'Parse list with self closing items.');
});

test('Preserve internal elements', function() {
	expect(2);

	var schema = new tinymce.html.Schema({valid_elements : 'b'});
	var counter = createCounter(writer);
	counter.validate = true;
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span id="id"><b>text</b></span><span id="id" data-mce-type="something"></span>');
	equal(writer.getContent(), '<b>text</b><span id="id" data-mce-type="something"></span>', 'Preserve internal span element without any span schema rule.');

	var schema = new tinymce.html.Schema({valid_elements : 'b,span[class]'});
	var counter = createCounter(writer);
	counter.validate = true;
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span id="id" class="class"><b>text</b></span><span id="id" data-mce-type="something"></span>');
	equal(writer.getContent(), '<span class="class"><b>text</b></span><span id="id" data-mce-type="something"></span>', 'Preserve internal span element with a span schema rule.');
});

test('Remove internal elements', function() {
	expect(2);

	var schema = new tinymce.html.Schema({valid_elements : 'b'});
	var counter = createCounter(writer);
	counter.validate = true;
	counter.remove_internals = true;
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span id="id"><b>text</b></span><span id="id" data-mce-type="something"></span>');
	equal(writer.getContent(), '<b>text</b>', 'Remove internal span element without any span schema rule.');

	var schema = new tinymce.html.Schema({valid_elements : 'b,span[class]'});
	var counter = createCounter(writer);
	counter.validate = true;
	counter.remove_internals = true;
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<span id="id" class="class"><b>text</b></span><span id="id" data-mce-type="something"></span>');
	equal(writer.getContent(), '<span class="class"><b>text</b></span>', 'Remove internal span element with a span schema rule.');

	// Reset
	counter.remove_internals = false;
});

test('Parse attr with backslash #5436', function() {
	var counter = createCounter(writer);
	var parser = new tinymce.html.SaxParser(counter, schema);
	writer.reset();
	parser.parse('<a title="\\" href="h">x</a>');
	equal(writer.getContent(), '<a title="\\" href="h">x</a>');
});
</script>
</head>
<body>
	<h1 id="qunit-header">tinymce.html.SaxParser tests</h1>
	<h2 id="qunit-banner"></h2>
	<div id="qunit-testrunner-toolbar"></div>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"></ol>
	<div id="content"></div>
</body>
</html>
